package com.sinoeyes.system.service.impl;

import java.util.List;

import com.sinoeyes.common.core.page.RestPageResult;
import com.sinoeyes.common.vo.BaseVo;
import com.sinoeyes.system.filter.SysNoticeFilter;
import com.sinoeyes.system.mapper.SysNoticeMapper;
import com.sinoeyes.system.po.SysNoticePo;
import com.sinoeyes.system.service.ISysNoticeService;
import com.sinoeyes.system.vo.SysNoticeVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 公告 服务层实现
 * 
 * @author ruoyi
 */
@Service
public class SysNoticeServiceImpl implements ISysNoticeService
{
    @Autowired
    private SysNoticeMapper noticeMapper;

    /**
     * 查询公告信息
     * 
     * @param noticeId 公告ID
     * @return 公告信息
     */
    @Override
    public SysNoticeVo selectNoticeById(Long noticeId)
    {
        return BaseVo.copyPo2Vo(noticeMapper.selectNoticeById(noticeId), SysNoticeVo.class);
    }

    /**
     * 查询公告列表
     * 
     * @param filter 公告信息
     * @return 公告集合
     */
    @Override
    public RestPageResult<SysNoticeVo> selectNoticeList(SysNoticeFilter filter) {
        filter.startPage();
        List<SysNoticePo> sysNoticePos = noticeMapper.selectNoticeList(filter);
        RestPageResult pageResult = filter.getPageResult(sysNoticePos);
        return BaseVo.copyPo2Vo(pageResult, SysNoticeVo.class);
    }

    /**
     * 新增公告
     * 
     * @param notice 公告信息
     * @return 结果
     */
    @Override
    public int insertNotice(SysNoticeVo notice)
    {
        return noticeMapper.insertNotice(BaseVo.copyVo2Po(notice, SysNoticePo.class));
    }

    /**
     * 修改公告
     * 
     * @param notice 公告信息
     * @return 结果
     */
    @Override
    public int updateNotice(SysNoticeVo notice)
    {
        return noticeMapper.updateNotice(BaseVo.copyVo2Po(notice, SysNoticePo.class));
    }

    /**
     * 删除公告对象
     * 
     * @param noticeId 公告ID
     * @return 结果
     */
    @Override
    public int deleteNoticeById(Long noticeId)
    {
        return noticeMapper.deleteNoticeById(noticeId);
    }
}
